<template>
  <div class="page-container" style="min-width: 1170px;">
    <el-form id="page_order_create" ref="form" :model="form" v-loading="loading"
      class="standard_form_gird standard_form_gird_right" label-position="right" label-width="140px">
      <ex_header_spiler :title="$t('label_customer_info')" v-if="!isCustomerSystem"></ex_header_spiler>

      <el-row v-if="!isCustomerSystem">
        <el-col>
          <el-form-item :label="$tt('label_customer', '客户')" prop="customerId" key="customerId">
            {{ $formatNameCode(form.customerName, form.customerCode) }}
          </el-form-item>
        </el-col>
      </el-row>
      <ex_header_spiler :title="$t('label_base_info')"></ex_header_spiler>
      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_sku_name_cn', '中文名称')" prop="skuName">
            {{ form.skuName }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_name_en', '英文名称')" prop="skuNameEn">
            {{ form.skuNameEn }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_sku_code', '商品条形码')" prop="skuBarcode">
            {{ form.skuBarcode }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_only_code', '商品唯一码')" prop="skuOnlyCode">
            {{ form.skuOnlyCode }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_sku_code_cn', '自定义商品编码')" prop="customNumber">
            {{ form.skuCode }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_unit')" prop="skuUnit">
            {{ form.skuUnit }}

          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_sell_unit')" prop="skuPrice">
            {{ $formatNameCode(form.skuPrice, form.currencyCode) }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_categ_info', '商品品类')" prop="categId">
            {{ form.categList ? form.categList.map(it => it.categoryName).join("/") : '' }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_provenance')" prop="skuOrigin">
            {{ form.skuOrigin }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_sku_material')" prop="skuMaterial">
            {{ form.skuMaterial }}

          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_sku_brand', '商品品牌')" prop="skuBrand">
            {{ form.skuBrand }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$tt('label_sku_model', '商品型号')" prop="skuModel">
            {{ form.skuModel }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_is_electrical')" prop="isElectrify">
            {{ $enumShow(form.isElectrify, 'YesOrNoEnum') }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <el-form-item :label="$t('label_sku_photo')" prop="skuUrl">
            <ex_image_view :src="form.skuUrl" :preview-src-list="[form.skuUrl]" class="image"
              style="width: 10rem;height: 10rem;" />
          </el-form-item>
        </el-col>
        <el-col>

          <el-form-item :label="$tt('label_sku_quality_equirement')" prop="skuQualityCheckType">
            {{ $enumShow(form.skuQualityCheckType, 'SkuQualityCheckTypeEnum') }}
          </el-form-item>
          <el-form-item v-if="form.skuQualityCheckType === 'SAMPLING'" :label="$tt('label_sku_sampling_ratio', '抽检比例')"
            prop="samplingRatio">
            {{ form.samplingRatio }}%
          </el-form-item>

          <el-form-item :label="$tt('label_quality_inspection_method')" prop="skuQualityCheckMethod">
            {{ $enumShow(form.skuQualityCheckMethod, 'SkuQualityCheckMethodEnum') }}
          </el-form-item>

          <el-form-item :label="$tt('label_quality_inspection_content')" prop="skuQualityCheckContent">
            {{ $enumShow(form.skuQualityCheckContent, 'SkuQulityCheckContentEnum') }}
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-form-item :label="$tt('label_sku_return_method')" prop="skuReturnMethod">
          {{ $enumShow(form.skuReturnMethod, 'SkuReturnMethodEnum') }}
        </el-form-item>
      </el-row>

      <el-row>
        <el-col :span="2">
          <el-form-item :label="$t('label_sku_link')" prop="skuDescUrl">
            <el-link type="primary">{{ form.skuDescUrl }}</el-link>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="2">
          <el-form-item :label="$tt('label_remark', '备注')" prop="skuRemark">
            {{ form.skuRemark }}
          </el-form-item>
        </el-col>
      </el-row>

      <ex_header_spiler :title="$t('label_declaration_info')"></ex_header_spiler>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_declared_categ_name_cn')" prop="skuDeclaredName">
            {{ form.skuDeclaredName }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_declared_categ_name_en')" prop="skuDeclaredNameEn">
            {{ form.skuDeclaredNameEn }}
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="HSCODE" prop="hsCode">
            {{ form.hsCode }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_declared_value')" prop="skuDeclaredValue">
            {{ $formatNameCode(form.skuDeclaredValue, form.currencyCode) }}
          </el-form-item>
        </el-col>
      </el-row>


      <ex_header_spiler :title="$t('label_dimension_weight_spec')"></ex_header_spiler>
      <el-row>
        <el-col :span="1">
          <el-form-item :title="$t('label_weight')" prop="skuWeight">
            {{ form.skuWeight }} kg
          </el-form-item>
        </el-col>
        <el-col :span="2">
          <el-form-item :title="$t('label_length_width_height')" prop="skuLength">
            {{ form.skuLength }} cm * {{ form.skuWidth }} cm * {{ form.skuHeight }} cm
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="1">
          <el-form-item :label="$tt('label_sku_full_load_weight_wordage', '满装重量')" prop="fullLoadOuterBoxWeight">
            {{ form.fullLoadOuterBoxWeight ? `${form.fullLoadOuterBoxWeight} kg` : '' }}
          </el-form-item>
        </el-col>
        <el-col :span="2">
          <el-form-item :label="$tt('label_sku_full_load_length_width_height', '满装长*宽*高')" prop="fullLoadOuterBoxLength">
            {{ (form.fullLoadOuterBoxLength && form.fullLoadOuterBoxWidth && form.fullLoadOuterBoxHeight) ?
              `${form.fullLoadOuterBoxLength} cm ${form.fullLoadOuterBoxWidth} cm ${form.fullLoadOuterBoxHeight} cm` : '' }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_carton_spec')" prop="cartonSpec">
            {{ $formatNameCode(form.cartonSpec, $enumShow(form.skuPackagingMethod, 'SkuPackageMethodEnum')) }}

          </el-form-item>
        </el-col>
      </el-row>
      <ex_header_spiler :title="$t('label_other')"></ex_header_spiler>
      <el-row>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_national_version_of_commodity', '商品国家版本')" prop="skuCountryVersion">
            {{ $enumShow(form.skuCountryVersion, 'SkuCountryVersionEnum') }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_buyer', '采购员')" prop="purchaser">
            {{ form.purchaser }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_developer', '开发员(选品)')" prop="developer">
            {{ form.developer }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item :label="$tt('label_certificate')" prop="certificateUrl">
            <ex_super_input ref="fileUpload" v-model="form.certificateUrl" type="upload-file" key="certificateUrl"
              readonly />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_instruction_book', '说明书')" prop="instructionUrl">
            <!-- <ex_super_input ref="fileUpload" v-model="form.instructionUrl" type="upload-file" key="instructionUrl"
              readonly /> -->
            <ex_super_upload type="file" v-model="form.instructionUrl" :limit="10" key="instructionUrl" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$tt('label_sku_inspection_declaration', '检测报关资料')" prop="customsDeclarationUrl">
            <!-- <ex_super_input ref="fileUpload" v-model="form.customsDeclarationUrl" type="upload-file"
              key="customsDeclarationUrl" readonly /> -->
            <ex_super_upload type="file" v-model="form.customsDeclarationUrl" :limit="10" key="customsDeclarationUrl" disabled />
          </el-form-item>
        </el-col>
      </el-row>


    </el-form>
  </div>
</template>

<script>
let default_obj = {
  cartonSpec: null,
  companyCode: null,//		string 	公司编号
  skuOnlyCode: null,//		string 	@NotBlank(message="sku编码不能为空")
  skuBarcode: null,//		string 	商品条形码（不唯一）英文字母需要统一转大写
  customerId: null,//		string 	客户ID
  customerCode: null,//		string 	客户编号
  skuName: null,//	string 	商品中文名称
  skuNameEn: null,//		string 	商品名称（EN）
  customNumber: null,//		string 	客户自定义编号（客户自己的商品编号映射我们系统的SKU）
  skuModel: null,//	string 	商品型号
  hsCode: null,//	string 	商品海关编码出口申报给海关的海关编码
  currencyCode: 'CNY',//		string 	label_declaration_currency人民币RMB/美元USD/日元JPY/欧元EUR/英镑GBP/港币HKD
  skuDeclaredValue: null,//			bigdecimal 	申报价值(USD)申报给海关的商品价值
  skuDeclaredName: null,//		string 	中文申报品名出口申报给海关的中文商品名称
  skuDeclaredNameEn: null,//		string 	英文申报品名出口申报给海关的英文商品名称
  skuPrice: null,//		bigdecimal 	商品单价
  skuUnit: null,//		string 	商品单位
  skuWeight: null,//			bigdecimal 	商品重量(KG)
  skuLength: null,//		bigdecimal 	长(CM)
  skuWidth: null,//		bigdecimal 	宽(CM)
  skuHeight: null,//		bigdecimal 	高(CM)
  skuUrl: null,//		,//		string 	商品图片地址
  skuDescUrl: null,//		string 	商品信息链接
  skuOrigin: null,//		string 	商品原产地
  skuMaterial: null,//		string 	商品材质
  skuBrand: null,//		string 	商品品牌
  skuRemark: null,//		string 	商品描述
  skuType: null,//		SkuTypeEnum 	LETTER:信封, PACKAGE:包裹
  skuPackagingMethod: 'BOX',//		SkuPackageMethodEnum 	BOX:箱, BALING:捆包, BAG:袋, BUCKET:桶
  skuStatus: null,//		SkuStatusEnum 	WAIT_SUBMIT:待提交, PENDING_PROCESS:待复核, WAIT_DELIVERY:待发货, DELIVERY:发货中, DISCARD:废弃, FAIL_PROCESS:审核驳回
  isCertificate: null,//			YesOrNoEnum 	Y:是, N:否
  isSnManage: null,//		YesOrNoEnum 	Y:是, N:否
  categList: [],
  categId: null,//		long 	二级品类
  skuPackagingRule: null,//			integer 	sku包装规则
  isOuterPackaging: null,//		YesOrNoEnum 	Y:是, N:否

  isUploadImg: null,//		YesOrNoEnum 	Y:是, N:否
  sharedSign: null,//		YesOrNoEnum 	Y:是, N:否
  sharedPrice: null,//			bigdecimal 	共享单价
  sharedTime: null,//		long 	共享时间
  version: null,//		long 	商品版本商品版本号
  isDelivery: null,//			YesOrNoEnum 	Y:是, N:否
  isElectrify: 'Y',//		YesOrNoEnum 	Y:是, N:否
  volumeType: null,//		MeasurementEnum 	LARGE:大尺寸, MEDIUM:中尺寸, SMALL:小尺寸
  isReceipt: null,//		string 	收货情况
  customerName: null,//		string 	所属客户名称
  deliveryTime: null,//		long 	发货日期
  certificateUrl: [],//		string 	证书
  skuReturnMethod: null,

  skuQualityCheckRequirement: null, // 商品质检要求
  skuQualityCheckType: 'SAMPLING', // SkuQualityCheckTypeEnum 商品质检方式: SAMPLING 抽检, COMPLETE_INSPECTION 全检
  samplingRatio: null, // 抽检比例全检为100%
  fullLoadOuterBoxLength: null, // 满装外箱长
  fullLoadOuterBoxWidth: null, // 满装外箱宽
  fullLoadOuterBoxHeight: null, // 满装外箱高
  fullLoadOuterBoxWeight: null, // 满装外箱重量
  instructionUrl: [], // 说明书地址信息集合
  customsDeclarationUrl: [], // 检测报关资料地址信息集合
  skuCountryVersion: null, // 商品国家版本
  purchaser: null, // 采购员
  developer: null, // 开发员(选品)
}
import role_system_mixin from '@/mixin/role_system_mixin';

import router_params from '@/mixin/router_params';
export default {
  title: 'label_sku_detail',
  mixins: [router_params, role_system_mixin],
  data() {
    return {
      loading: false,
      form: _.cloneDeep(default_obj),
    }
  },

  methods: {
    fixTabLabel() {
      this.$emit("tagModifyLabel", { _key: 'label_name_code', i18n: { name: true }, name: "label_sku_detail", code: this.form.skuName })
    },
    init_order(id) {
      this.loading = true
      let data = {
        id
      }
      this.$ajax({
        url: !this.isCustomerSystem ? "/mms-api/sku/MmsSkuInfoRpc/detail.json" : "/mms-api/client/MmsSkuInfoClientRpc/detail.json",
        method: 'post',
        data,
        success: (res) => {
          if (!res.data) return this.$message.error(this.$tt("label_data_loss"))
          this.form = res.data
          this.loading = false
          this.fixTabLabel()
        },

      })
    },
    init_data_default(params) {
      this.init_order(params.id)
    },
  }
}
</script>

<style scoped></style>
